<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>编辑审核状态</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  <script src="/scripts/jquery.min.js"></script>
  <script src="/scripts/boot.js" type="text/javascript"></script>
  <script src="/scripts/miniui/miniui.js"></script>

  <style type="text/css">
    html, body {
      font-size: 12px;
      padding: 0;
      margin: 0;
      border: 0;
      height: 100%;
      overflow: hidden;
    }
  </style>
</head>
<body>

<!--<form id="form1" name="form1" method="post" action='/tribeRoute/addTribeMember' enctype="text/plain" >-->
<form id="form1" name="form1">
  <input name="objectId" class="mini-hidden" />
  <input name="userOId" class="mini-hidden" />
  <input name="oldShopStatus" class="mini-hidden" />
  <div style="padding-left:11px;padding-bottom:5px; margin-top: 20px">
    <table style="table-layout:fixed; margin: 0 auto;text-align: center;">
      <tr>
        <td style="width:60px;">申请人：</td>
        <td >
          <input name="name" class="mini-textbox" style="width:200px;margin-right: 20px;" type="text" allowInput="false"/>
        </td>
        <td style="width:60px;">身份证号：</td>
        <td >
          <input name="identityCardNo" class="mini-textbox" style="width:200px;" type="text"  allowInput="false"/>
        </td>
      </tr>
      <tr>
        <td style="width:60px;">电话：</td>
        <td >
          <input name="tel" class="mini-textbox" style="width:200px;margin-right: 20px;" type="text"  allowInput="false"/>
        </td>
        <td style="width:60px;">审核状态：</td>
        <td >
          <input id="shopStatus" name="shopStatus" class="mini-combobox" style="width:200px;" type="text" required="true" data="shopStatus" onvaluechanged="statusChange"/>
        </td>
      </tr>
      <tr>
        <div id="reasonTR" name="reasonTR" >
          <td style="width:60px;">审核备注：</td>
          <td>
            <div id="reason" class="mini-radiobuttonlist" repeatItems="2" repeatLayout="table" repeatDirection="vertical"
                 textField="text" valueField="id" value="1"
                 data="reason" >
            </div>
            <input id="reasonText" class="mini-textarea" style="width:200px;margin-right: 20px;" type="text"/>
          </td>
        </div>
      </tr>
    </table>
  </div>
  <div style="text-align:center;padding:10px; margin-top: 10px">
    <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
    <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
  </div>
</form>
<script type="text/javascript">
  var reason = [{ id: 1, text: '身份信息与证件不符！' },{ id: 2, text: '手持身证件不够清晰！' }];
  var shopStatus = [{ id: 0, text: '未审核' },{ id: 1, text: '审核成功' },{ id: 2, text: '审核失败' }, { id: 3, text: '审核中'}];
  mini.parse();
  if(mini.get("reason").value == '2'){
    mini.get("reason").show();
    mini.get("reasonText").hide();
  } else {
    mini.get("reason").hide();
    mini.get("reasonText").show();
  }

  var form = new mini.Form("form1");
  function SaveData() {
    var form = new mini.Form("#form1");
    form.validate();
    var data = form.getData();
//    console.log(data);
    if (data.shopStatus == data.oldShopStatus) {
      alert('数据无变化！');
      return;
    }

    if (data.shopStatus == '2'){
      var reason = mini.get("reason");
      data.reason = reason.getText();
    } else if (data.shopStatus == '1') {
      if (mini.get("reasonText").getValue() == ''){
        data.reason = '审核通过';
      }
    } else {
      var reason = mini.get("reasonText");
      data.reason = reason.getValue();
    }
//    console.log(data);
    $.ajax({
      url: "/getdata/shopVerifyMangerEditHandle",
      type: 'post',
      data: data,
      cache: false,
      success: function (res) {
        var resultData = JSON.parse(res);
        alert(resultData);
        CloseWindow("ok");
      },
      error: function (error) {
        console.log(error)
      }
    });
  }
  ////////////////////
  //标准方法接口定义
  function SetData(data) {
//    console.log(data);
    if(data) {
      var verifyData = mini.clone(data);
      mini.getbyName("objectId").setValue(verifyData.objectId);
      mini.getbyName("userOId").setValue(verifyData.userOId);
      mini.getbyName("name").setValue(verifyData.name);
      mini.getbyName("identityCardNo").setValue(verifyData.identityCardNo);
      mini.getbyName("shopStatus").setValue(verifyData.shopStatus);
      mini.getbyName("tel").setValue(verifyData.tel);
      mini.getbyName("oldShopStatus").setValue(verifyData.shopStatus);
    }
  };
  function statusChange(e) {
    if(e.value == '2'){
      mini.get("reason").show();
      mini.get("reasonText").hide();
    } else {
      mini.get("reason").hide();
      mini.get("reasonText").show();
    }
  };
  function GetData() {
    var o = form.getData();
    return o;
  }

  function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
      if (confirm("数据被修改了，是否先保存？")) {
        return false;
      }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }

  function onOk(e) {
    SaveData();
  }

  function onCancel(e) {
    CloseWindow("cancel");
  }

</script>
</body>
</html>
